﻿using SysSurv.bll;
using SysSurv.dtl;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;

namespace SysSurv
{
    public partial class frmResults : Form
    {
        public frmResults()
        {
            InitializeComponent();
        }

        private void frmResults_Load(object sender, EventArgs e)
        {
            cmbQuestions.DataSource = Wiii.getInstance().srvAux.lstQuestions;
        }

        private void cmbQuestions_SelectedIndexChanged(object sender, EventArgs e)
        {
            lstResults.DataSource = null;
            long pId = ((Question)cmbQuestions.SelectedItem).i64Id;
            RestClient client = new RestClient("http://localhost:8080/SpringSurv/surveys/stats/" + pId, HttpVerb.GET, "", true);
            string response = client.MakeRequest();
            List<string> lstStat = new JavaScriptSerializer().Deserialize<List<string>>(response);
            lstResults.DataSource = lstStat;
        }
    }
}
